<script>
export default {
  onLaunch() {

    // uni-app客户端获取push客户端标记，代码可以实现在App.vue中
    uni.getPushClientId({
      success: (res) => {
        let push_clientid = res.cid
        console.log('客户端推送标识cid:', res)
        //设置自己的cid
        this.$api.setPushCid({
          cid: push_clientid
        }).then(res => {
          console.info("设置cid结果", res)
        })
      },
      fail(err) {
        console.log("客户端推送标识错误", err)
      }
    })
    console.log('App Launch')
    uni.onPushMessage((res) => {
      console.log("收到推送消息：", res) //监听推送消息
    })
    console.log(11111111111111111111111111)
    //存放后端给你传的变量
    plus.push.addEventListener("receive", function (msg) {
      console.log("receive", msg)
      let id = msg.payload.body.id; //这块打印出来看你需要什么值再进行赋值
    }, false);

    //点击系统通知的推送跳转到指定的界面
    plus.push.addEventListener("click", function (msg) {
      console.log("点击了通知消息", msg)
      setTimeout(function () {
        uni.navigateTo({
          url: '/pages/noteDetail/NoteDetail?noteId=' + msg.payload.id,
          fail: function (e) {
            console.log("失败了", e)
          }
        })
      }, 1000)
      plus.push.clear();
    }, false);

  },
  onShow: function () {
    //console.log('App Show')
  },
  onHide: function () {
    //console.log('App Hide')
  },
  methods: {}
}
</script>

<style lang="scss">
/*每个页面公共css */
@import './static/css/style.css';

.bgf {
  background: #FFF;
}

.flc {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flc-inline {
  display: inline-flex;
  align-items: center;
}

.g5 {
  color: $g5;
}

.fz12 {
  font-size: $fz12;
}
</style>
<style>
@import url("/components/gaoyia-parse/parse.css");
</style>